package com.cskaoyan.app.wxcontroller;

import com.cskaoyan.app.bean.common.BaseRespVo;
import com.cskaoyan.app.bean.po.MarketFeedback;
import com.cskaoyan.app.exception.ValidationException;
import com.cskaoyan.app.util.ValidationUtil;
import com.cskaoyan.app.wxservice.WxFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wx/feedback")
public class WxFeedbackController {

    @Autowired
    private WxFeedbackService feedbackService;

    @PostMapping("submit")
    public BaseRespVo<Object> submit(@RequestBody @Validated MarketFeedback feedback,
         BindingResult bindingResult) throws ValidationException {
        ValidationUtil.valid(bindingResult);
        feedbackService.addFeedback(feedback);
        return BaseRespVo.ok();
    }
}
